<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
		<%@ include file="/WEB-INF/views/include/common.jsp" %>
		<meta name="AUTHOR" content="QroTech Inc." />
		<title>큐로넷::위치관제시스템</title>
		
		
		
		<link rel="stylesheet" href="${cssUrl}/header-1.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/fancy_table.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/menu.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/table.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/button.css" type="text/css" />
		<link rel="stylesheet" href="${cssUrl}/m-300.css" type="text/css" />
		
		
		<script src="${jsUrl}/m-300.js"></script>
			
<script >
	var _this = this;
	function init(){
		
		
		var carList = [
			<c:forEach items="${carList }" var="car" varStatus="status">
			{
				dep_DeptName:'${car.dep_DeptName}',
				carRegiNumber:'${car.carRegiNumber}',
				carName:'${car.carName}',
				dri_Name:'${car.dri_Name}',
				carGroupName:'${car.carGroupName}',
				carTypeName:'${car.carTypeName}',
				carCode:'${car.carCode}',
				carType:'${car.carType}',
				cus_SubscriptionDate:'${car.cus_SubscriptionDate}',
				cus_OnSubscription:'${car.cus_OnSubscription}',
				cus_DetectTime:'${car.cus_DetectTime}',
				dev_PhoneNum:'${car.dev_PhoneNum}',
				deptCode:'${car.deptCode}',
				carGroupCode:'${car.carGroupCode}',
				bag_BaggageName:'${car.bag_BaggageName}',
				baseTotalDistance:'${car.baseTotalDistance}',
				customerCode:'${car.cus_CustomerCode}',
				cus_CustomerCode:'${car.cus_CustomerCode}',
				dri_HandPhone:'${car.dri_HandPhone}',
				garage:'${car.garage}',
				memo:'${car.memo}',
				regulationSpeed:'${car.regulationSpeed}',
				lowVoltage:'${car.lowVoltage}',
				baeTemperature1:'${car.baeTemperature1}',
				baeTemperature2:'${car.baeTemperature2}',
				GPSAllowTimeFr:'${car.GPSAllowTimeFr}',
				GPSAllowTimeTo:'${car.GPSAllowTimeTo}'
			}
			${not status.last ? ',' : ''}
			</c:forEach>
		]
		
		
		initTableSync();
		_this.carInfoTbl1.tableAutoSync(carList);
		carInfoTbl1TrOnClick();
		initBind();
	}
	
	function carInfoTbl1TrOnClick(){
		$('.setCheck').unbind('click');
		
		
		$('.setCheck').bind('click', function(){
			var p = $(this).parent();
			logs(p);
// 			logs($(this).parent().find('input[type=check]'));
// 			logs(!$(this).parent().find('input[type=check]').is(':checked'));
			p.find('input[type=checkbox]').prop('checked', !p.find('input[type=checkbox]').is(':checked'));
			
			p.find('input[type=checkbox]').trigger('change');
			
		});
		
// 		$('#carInfoTbl1 >tbody>tr>td:gt(0)').bind('click', function(){
// 			console.log('a');
// 			logs(!$(this).parent().find('input[type="check"]').is('checked'));
// 			$(this).parent().find('input[type="check"]').prop('checked', !$(this).parent().find('input[type="check"]').is('checked'));
// 		});
	}

	function chooseCarType(type){
		autoSync('carInfo', {carType:type});
		$('#carTypeSrc').attr('src',makeCarTypeSrcUrl(type));
		$('.popup_close').trigger('click');
	}
	
	function searchCar(){
		var url = '/envInfo/searchCar.json';
		
		var key = $('select#searchType').val();
		logs(key);
		var val = $('input[name=searchValue]').val();
		
		var param = key+'='+val;
		
		if(val.length==0) param='';
		
		
		AjaxPost(url, param, function(data){
			
			try{
				$(data.carList).each(function(){
					this['customerCode']=this['cus_CustomerCode'];
				});	
			}catch(e){logs(e);}
			
			
			_this.carInfoTbl1.tableAutoSync(data.carList);
			carInfoTbl1TrOnClick();
			
			$('#carListCnt').text(data.carListCnt);
			autoSync('userDetailInfo', carInfoMgrObj.getEmpty());
			clearSelectOptions();	// select box들을 초기화 시켜준다.
			carInfoMgrObj.clearItem();
			
			$('input[name=carCodeChk]').each(function(){
				if($(this).is(':checked')){
					$(this).prop('checked', false);	
				}
			});
			
			_this.SSck.bind();	// check box 새롭게 바인딩 해주기.
		});
	}
	
	var timeTo=0, timeFr=0;
	function initBind(){
		 $('input[name=baseprivacy]').unbind('change');
		 $('input[name=baseprivacy]').bind('change', function(){
			 if($(this).val()==0){
				 timeFr = $('select#GPSAllowTimeFr').val();
				 timeTo = $('select#GPSAllowTimeTo').val();
				 $('select#GPSAllowTimeFr').val(0);
				 $('select#GPSAllowTimeTo').val(0);
			 }else{
				 $('select#GPSAllowTimeFr').val(timeFr);
				 $('select#GPSAllowTimeTo').val(timeTo);
			 }
		 });
		 
		 $('.selectChanged').unbind('change');
		 $('.selectChanged').bind('change', function(){
			 setRadioBaseprivacy(1);
		 });
		 
		 $('#saveCarInfo').unbind('click');
		 $('#saveCarInfo').bind('click', function(){
			 checkChangedDetailInfo('carInfo');
		 });
		 
		 $('#savePrivacy').unbind('click');
		 $('#savePrivacy').bind('click', function(){
			 checkChangedDetailInfo('privacyInfo');
		 });
		 
		 
// 		 $('input[data-id="check1"][data-check="parent"]').bind('change', function(){
// 			 logs('1');
// 			 alert($(this).attr('checked'));
// 		 });
		 _this.SSck = new SS_InputCheck('check1');
		 _this.GroupCk = new SS_InputCheck('chk_group');
		 
		 $('#btnGroupDelete').unbind('click');
		 $('#btnGroupDelete').bind('click', function(){
			 deleteGroupItem();
		 });
		 
		 $('#btnGroupAdd').unbind('click');
		 $('#btnGroupAdd').bind('click', function(){
		 
			 var newName =$('input[id="newGroupName"]').val(); 
			 var regExp1 = /\w/g;
			 var regExpK = /[ㄱ-힝]/g;
			 var ret = '';
			 ret = newName.replace(regExp1,'').replace(regExpK,'').replace(/\s/g,'');
			 
			 if(ret.length>0){
				 alert('"한글, 영어, 숫자, _, 공백" 외의 문자열은 입력이 불가합니다.');
				 return;
			 }
			 var notAllowed=['미지정', 'Undefined', '기본그룹', 'Default Group'];
			 for(var index in notAllowed){
				 logs(newName.trim().indexOf(notAllowed[index]));
				 logs(notAllowed[index]);			 
				 if(newName.trim().indexOf(notAllowed[index])>-1){
					 alert('"미지정, Undefined, 기본그룹, Default Group"는 금지어입니다.');
					 return;
				 }
			 }
			 var url = '/envInfo/addGroupItem.json';
			 var param = 'newName='+newName;
			
			 AjaxPost(url, param, function(data){
				 alert('성공!');
				 searchCar();				 
			 });
			 
		 });
	}
	
	function deleteGroupItem(){
		var text='', ids='';
		var item = getCheckedVal();
		for(var i in item){
			
			text += item[i].text+', ';
			ids += item[i].val+',';
		}
		logs(carInfoMgrObj.getOutJson()['customerCode']);
		
		if(text.length>0){
			text = text.substring(0, text.trim().length-1);
			ids = ids.substring(0, ids.length-1);
			logs('text = '+text+'\nids = '+ids);
			var msg = '선택된\n['+text+']\n항목을 삭제하시겠습니까?';
			if(confirm(msg)){
				
				var url = '/envInfo/deleteGroupItem.json';
				var param = 'carGroupCodes='+ids;
				
				AjaxPost(url, param, function(data){
					alert(data.result);
					if(data.result.trim()=='성공'){
						searchCar();
						deleteCheckedGroup();	
					}
				});
			}
		}
	}
	
	function deleteCheckedGroup(){
		$('input[data-id="chk_group"][data-check="children"]').each(function(){
			if($(this).is(':checked')){
				var p = $(this).parent().parent();
				p.remove();
			}
		});
	}
	
	/**
	* 그룹리스트에서 체크된 항목을 찾는다.
	*/
	function getCheckedVal(){
		var checked = [];
		$('input[data-id="chk_group"][data-check="children"]').each(function(){
			if($(this).is(':checked')){
				var p = $(this).parent().parent();
				var item = {};
				logs('val = '+p.find('#carGroupCode').val());
				logs('text = '+p.find('#groupName').text());
				
				item.val = p.find('#carGroupCode').val();
				item.text = p.find('#groupName').text();
				checked.push(item);
			}
		});
		
		return checked;
	};
	
	function SS_InputCheck(dataId){
		this._this = this;
		
		this.dataId = dataId;
		this.bind();
	}
	
	
	
	SS_InputCheck.prototype.getDataId = function(){
		return this.dataId;
	}
	
	SS_InputCheck.prototype.bind = function(){

		var SS = this._this;
		$('input[data-id="'+this.dataId+'"][data-check="parent"]').unbind('change');
		$('input[data-id="'+this.dataId+'"][data-check="parent"]').bind('change', function(){
			SS.changeAllChildren($(this).is(':checked'), SS);	// 전부를 변하게 한다.
			
		 });
		$('input[data-id="'+this.dataId+'"][data-check="children"]').unbind('change');
		$('input[data-id="'+this.dataId+'"][data-check="children"]').bind('change', function(){
			SS.setParentCheck(SS.isAllChekced(SS), SS); 
		 });
	};
	
	/**
	* 모든 childred을 변하게 한다. 
	* param : boolean flag
	*/
	SS_InputCheck.prototype.changeAllChildren = function(flag, SS){
		logs('changeAllChildren _ flag = '+flag);
		var ck = flag?'checked':false;
		
		$('input[data-id="'+SS.dataId+'"][data-check="children"]').each(function(){
			$(this).prop('checked', ck);
			logs(ck);
		});
	};
	
	/**
	* parent 를 변하게 한다.
	* param : boolean flag
	*/
	
	SS_InputCheck.prototype.setParentCheck = function(flag, SS){
		logs('setParentCheck _ flag = '+flag);
		var ck = flag?'checked':false;
		$('input[data-id="'+SS.dataId+'"][data-check="parent"]').prop('checked', ck);
	}
	
	/**
	* 모두 체크 되었는지 확인한다.
	*/
	SS_InputCheck.prototype.isAllChekced = function(SS){
		var ret = true;
		$('input[data-id="'+SS.dataId+'"][data-check="children"]').each(function(){
			logs("$(this).is('checked') = "+$(this).is(':checked'));
			if(!$(this).is(':checked')){
				ret = false;
				return false;	// break;
			}
		})
		return ret;
	}
	
	/**
	* 체크된 자식의 숫자를 리턴한다.
	*/
	SS_InputCheck.prototype.getChcekedCount = function(){
		var ret = 0;
		$('input[data-id="'+this.dataId+'"][data-check="children"]').each(function(){
			if($(this).is(':checked')) ret++;		
		})
		return ret;
	}
	
	
	
	function checkChangedDetailInfo(id){
		 var carInfo = getToJSON($('#'+id));
		 carInfo = changeJsonObject(carInfo);
		 var outObj = carInfoMgrObj.outObj;
		 var changed = false;
		 var diffObj={};
		 for(var key in carInfo){
			 if(outObj.hasOwnProperty(key)){
				 if(key=='GPSAllowTimeTo'||key=='GPSAllowTimeFr'){
					 if(carInfo[key]==null && outObj[key].toString()=='-1'){
						 continue;
					 }
					 if(outObj[key]==null && carInfo[key].toString()=='-1'){
						 continue;
					 }	 
				 }
				 if(checkTheSame(carInfo[key], outObj[key])){
					 changed = true;
					 
					 if(key == 'carGroupCode' && (carInfo[key] == null || carInfo[key] == 'null')){
						 carInfo[key]='';
						 logs('key = '+key);
					 }
					 
					 diffObj[key]=carInfo[key];
				 }
			 }
		 }
		 
		 if(changed){
			 jsonLog(diffObj);
			 updateCarDetailInfo(diffObj);
		 }
	}
	
	/**
	* 변경된 사항을 저장한다.
	*/
	function updateCarDetailInfo(diffObj){
		var checkedItemLength = carInfoMgrObj.checkedItem.length;
		switch(checkedItemLength){
		case 0: return;
		case 1:{
			var item = carInfoMgrObj.checkedItem[0];
			var str = '차량['+item['carRegiNumber']+']님의 정보를 변경합니까?';
			if(confirm(str)){
				updateInfo(diffObj);
			}
			break;
		}
		default:{
			if(confirm('체크된 항목이 모두 변합니다.\n진행합니까?')){
				updateInfo(diffObj);
			}
		}
		}
	}
	
	function updateInfo(obj){
		try{
			var url = '/envInfo/updateInfo.json';
			var param = jsonToUrlParam(obj)+'&checkedCarCodes='+carInfoMgrObj.getCarCodes();
			
			AjaxPost(url, param, function(data){
// 				alert('성공!');
				searchCar();
			});
		}catch(e){logs(e);}
	}
	
	/**
	* 같으면 fasle, 다르면 true
	*/
	function checkTheSame(val1, val2){
		var ret = true;
		
		try{
			if(val1==null && val2==null) return ret=false;
			if(val1=='' && val2 =='') return ret=false;
			if(val1=='null' && val2 =='') return ret=false;
			if(val1=='' && val2 =='null') return ret=false;
			if(typeof val1 == 'null' && typeof val2 == 'null') return ret=false;
			if(val1==null && val2 =='') return ret=false;
			if(val1=='' && val2 ==null) return ret=false;
			if(typeof val1 == null && typeof val2 == null) return ret=false;
			if(typeof val1 == 'undefined' && typeof val2 == 'undefined') return ret=false;
			if(val1 == val2) return ret=false;
		}catch(e){
			logs(e);
		}
		finally{
			return ret;
		}
	}
	
	function makeCarTypeSrcUrl(carType){
		var carTypeSrc='999';
 		try{
 			if(parseInt(carType)){
 				carTypeSrc = parseInt(carType);
 			}
 		}catch(e){}
 		return '${imgUrl}/icon_cartype_'+carTypeSrc+'.png';
	}
	
	function initTableSync(){
		_this.carInfoTbl1 = tableSync('carInfoTbl1');
		_this.tblMgrCarGroup = tableSync('tblMgrCarGroup');
	}
	
	function isNull(obj){
		if(typeof obj == 'null') return true;
		if(typeof obj == 'undefined') return true;
		if(obj.length == 0) return true;
		if(obj == '') return true;
		return false;
	}

	var carInfoMgrObj = {
		checkedItem:[],
		empty:{},
		outObj:{},
		getEmpty : function(){return this.empty;},
		clearItem : function(){
			this.checkedItem = [];
			this.outObj={};
		},
		setItem : function(obj){
			this.checkedItem.push(obj);
			if(this.checkedItem.length>1){
				$('.top a').hide();
			}else{
				$('.top a').show();
			}
		},
		getOutJson: function(){
			var itemLength = this.checkedItem.length;
			var outObj={};
			switch(itemLength){
			case 0 : return this.empty;
			case 1 : {
				outObj=this.checkedItem[0];
				for(var key in outObj){
					this.empty[key]='';
				}
				break;
			}
			default :{	// 선택된 checkBox가 2개 이상일 때
				var tmpObj={};
				$(this.checkedItem).each(function(){
					for(var key in this){
						if(!outObj[key] && !tmpObj[key]){
							outObj[key] = this[key];
							tmpObj[key] = this[key];
						}else{
							if(tmpObj[key] != this[key]){
								outObj[key] = '';	
							}
						}	
					}
				});
				
				
// 				var serviceInfo = getToJSON($('#serviceInfo'));	//서비스 정보 항목은 모두 삭제한다.
				for(var key in getToJSON($('#serviceInfo'))){
					outObj[key] = '';
				}
				
				break;
			}
			}
			
			outObj = changeJsonObject(outObj);
	 		
			return this.outObj = outObj;
		},
		getCarCodes:function(){
			var carCodes=[];
			$(this.checkedItem).each(function(){
				carCodes.push(this['carCode']);
			});
			return carCodes;
		}
	}
	
	function changeJsonObject(json){
		// 이미지 src 설정
		if(json['carType']){
			json['carTypeSrc'] = makeCarTypeSrcUrl(json['carType']);	
		}
 		
 		
 		if(json['cus_SubscriptionDate']!=null && json['cus_SubscriptionDate'].length>0){
 			var dateForm = json['cus_SubscriptionDate'].split('-');
	 		json['cus_SubscriptionDate'] =	cus_SubscriptionDate = dateForm[0]+'년 '+dateForm[1]+'월 '+dateForm[2]+'일';
 		}
 		
 		if(json['cus_OnSubscription']!=null && json['cus_OnSubscription'].length>0){
 			json['cus_OnSubscription'] = json['cus_OnSubscription']=='y'?'GPS 서비스':'서비스가 없습니다.';			 			
 		}
 		return json;
	}
	
	function chooseCar(tr){
		carInfoMgrObj.clearItem();
		$('input[name=carCodeChk]').each(function(){
			if($(this).is(':checked')){
				carInfoMgrObj.setItem(getToJSON($(this).parent().parent()));	
			}
		});
		var retJson = carInfoMgrObj.getOutJson(); 
		logs('chooseCar');
		jsonLog(retJson);
		if(retJson && retJson.carCode){
			$('#theForm').find('input[name="carCode"]').val(retJson.carCode);
		}
		clearSelectOptions();	// select box들을 초기화 시켜준다.
		
		if(retJson['customerCode'].length>0){	// customerCode가 같을 때만.
			var url = '/envInfo/carDetailInfoMng.json';
			var param = 'customerCode='+retJson.customerCode;
			AjaxPost(url, param, function(data){
				$(data.deptList).each(function(){
					appendOpt('deptCode', this.deptCode, this.deptName);	
				});
				
				$(data.carGroup).each(function(){
					appendOpt('carGroupCode', this.carGroupCode, this.groupName);	
				});
				
				_this.tblMgrCarGroup.tableAutoSync(data.carGroup);
				
				_this.GroupCk.bind();	/// check box 바인딩.
				
				autoSync('userDetailInfo', retJson);
				// 프라이버시설정 radio 선택
				settingRadioBaseprivacy(retJson);
			});
		}else{
			
			autoSync('userDetailInfo', retJson);
			// 프라이버시설정 radio 선택
			settingRadioBaseprivacy(retJson);
		}
	}

	// select box들을 초기화 시켜준다.
	function clearSelectOptions(){
		$('select#deptCode option').each(function(){
			$(this).remove();
		});
		$('select#carGroupCode option').each(function(){
			$(this).remove();
		});
	}
	// 프라이버시설정 radio 선택
	function settingRadioBaseprivacy(jsonObj){
		var $radios = $('input:radio[name=baseprivacy]');
		var from = parseInt(jsonObj.GPSAllowTimeFr);
		var to = parseInt(jsonObj.GPSAllowTimeTo);
		var setValue = 0;
		if(from>0 && to>0){
			setValue=1;
		}
		$radios.filter('[value='+setValue+']').prop('checked', true);
	}
	
	function setRadioBaseprivacy(value){
		var $radios = $('input:radio[name=baseprivacy]');
		$radios.filter('[value='+value+']').prop('checked', true);
	}

	function gotoM120(){
		var checkedItemLength = carInfoMgrObj.checkedItem.length;
		switch(checkedItemLength){
		case 0: return;
		case 1:{
			var o  = document.createElement("form"); 
	        var carCode = document.createElement("input"); 
	        carCode.name = 'carCode'; 
	        carCode.type = 'hidden';
	        carCode.value = carInfoMgrObj.getOutJson().carCode; 
	        o.appendChild(carCode); 
	        document.body.appendChild(o); 
	        o.method = 'post'; 
	        o.action = '/map/carRootDetail'; 
	        o.submit(); 
			break;
		}
		default :{
			alert('차량을 한 대만 선택해 주세요.');
		}
		}
	}

	function regiDestinationPopup() {
		if(_this.SSck.getChcekedCount()==1){
			window.open('/map/getRegDestinationPopup', 'regDestination', 'width=920, height=600, scrollbars=yes, location=no');	
		}
		
	}
	
</script>		
    </head>
    <body onload="javascript:init();">
    	<div id="overlay" class="overlay" >
    	</div><!-- contentWrapper end -->
    	<div class="headerContent">
	
		<div class="pageHeader">
			<%@ include file="/WEB-INF/views/include/logoLink.jsp" %>
			<div id="pageNav">
				<ul>
<!-- 					<a href="/totalCarListMain" class="togglerHeader"><li class="hmenu0" id="hdmenu0"></li></a> -->
<!-- 					<a href="#" class="togglerHeader"><li class="hmenu1" id="hdmenu1"></li></a> -->
<!-- 					<a href="#" class="togglerHeader"><li class="hmenu2" id="hdmenu2"></li></a> -->
<!-- 					<a href="#" class="togglerHeader"><li class="hmenu3" id="hdmenu3"></li></a> -->
					<%@ include file="/WEB-INF/views/include/mainNaviStyle2.jsp" %>
				</ul>
			</div>
			<div id="pageNavRight">
				<%@ include file="/WEB-INF/views/include/titleLink.jsp" %>
			</div>
		</div>
			<div class="header_line"></div>
		</div><!--header end-->	
	
        
        	<div class="secondMenu" >
					<div id="menu">
						<ul>
							<%@ include file="/WEB-INF/views/include/innerNavi.jsp" %>
						</ul>
					</div>
						
				</div><!-- second menu end -->
			
			<div class="m300height">	
			<div class="mainContent">	
				<div class="searchInfo">
					<ul>
						<li class= "locationInfo"><span>차량정보</span></li>
						<li class="totalSearchNum"><span id="carListCnt">${carListCnt}</span>대 / 총 ${carListCnt}대</li>
						<li class='textSearch'>차량 검색</li>
						<li class="choices">
							<select id="searchType">
								<option value="carRegiNumber">차량번호</option>
								<option value="dri_Name">운전자명</option>
								<option value="carName">차량별칭</option>
								<option value="dep_DeptName">소속</option>
								<option value="carGroupName">관리그룹</option>
								<option value="carTypeName">차량종류</option>
							</select>
						</li>
						<li class="inputSearch"><input type="text" name="searchValue"></li>
						<li class="search_button" onclick="javascript:searchCar();"><a><img id="popup" src="${imgUrl}/black_box.png"></a></li>
					</ul>
					<div class="last"><a onclick="javscript:openQuestionPopup('http://www.qronet.co.kr/help/qronet_help.html#CarManagement')"><img src="${imgUrl}/question_mark.png"></a></div>
				</div><!-- searchInfo end -->
				<div class="leftAndRight">
					<div class="leftContent">
						<div class="insideContentLeft">
							<div class="chart300"> 
							<p>* 검색된 차량을 선택하면 오른쪽 상세 정보를 조회 및 수정할 수 있습니다.</p>
								<div class="chart_head" >
									<table  valign="top" cellpadding="0" cellspacing="0"> 
										<tr valign="top" >
											<th width="30px"><input type="checkbox" data-id="check1" data-check="parent"></th>
											<th width="90px">소속</th>
											<th width="95px">차량번호</th>
											<th width="95px">차량별칭</th>
											<th width="70px">운전자명</th>
											<th width="75px">관리그룹</th>
											<th width="*">차량종류</th>
											<th style="display:none;">
											</th>
										</tr>	
										
									</table>
								</div><!--chart_head end-->
								<div class="chart_body">
									<table id="carInfoTbl1" cellpadding="0" cellspacing="0">
										<tbody> 
										<tr valign="top">
											<td width="30px"><input type="checkbox" id="carCode" name="carCodeChk" onchange="chooseCar(this)" data-id="check1" data-check="children"></td>
											<td width="90px" id="dep_DeptName" class="setCheck">큐로넷 영업부</td>
											<td width="95px" id="carRegiNumber" class="setCheck">서울01가5555</td>
											<td width="95px" id="carName" class="setCheck">서울01가5555</td>
											<td width="70px" id="dri_Name" class="setCheck">김큐로넷</td>
											<td width="75px" id="carGroupName" class="setCheck">이것은 관리그룹1</td>
											<td width="*" id="carTypeName" class="setCheck">덤프트럭</td>
											<td style="display:none;">
												<input type="hidden" id="carType"/>
												<input type="hidden" id="cus_SubscriptionDate"/>	<!-- 서비스가입일 -->
												<input type="hidden" id="cus_OnSubscription"/>	<!-- 서비스구분 -->
												<input type="hidden" id="cus_DetectTime"/>	<!-- 최근수신시각 -->
												<input type="hidden" id="customerCode"/>
												<input type="hidden" id="dev_PhoneNum"/>	<!-- 단말기 번호 -->
												<input type="hidden" id="deptCode"/>	<!-- 부서코드 -->
												<input type="hidden" id="carGroupCode"/>	<!-- 그룹코드 -->
												<input type="hidden" id="dri_HandPhone"/>	<!-- 운전자 전화번호 -->
												<input type="hidden" id="bag_BaggageName"/>	<!-- 운반물 내용 -->
												<input type="hidden" id="baseTotalDistance"/>	<!-- 누적거리 -->
												<input type="hidden" id="garage"/>	<!-- 차고지 -->
												<input type="hidden" id="memo"/>	<!-- 메모 -->
												<input type="hidden" id="regulationSpeed"/>	<!-- 규정속도 -->
												<input type="hidden" id="lowVoltage"/>	<!-- 저잔압설저 -->
												<input type="hidden" id="baeTemperature1"/>	<!--  -->
												<input type="hidden" id="baeTemperature2"/>	<!--  -->
												<input type="hidden" id="GPSAllowTimeFr"/>	<!--  -->
												<input type="hidden" id="GPSAllowTimeTo"/>	<!--  -->
												
											</td>
										</tr>
										</tbody>
									</table>	
								</div><!-- chart_body end -->
							</div><!-- chart300 end-->
						</div>
					</div>
					<div class="rightContent">
						<div class="insideContentRight">
							<div class="content" id="userDetailInfo">
								
									<div class="top">
											<span class="plate">차량번호 : </span><span id="carRegiNumber"></span>
											<span class="buttons">
												<a  class="button1" onclick="javascript:regiDestinationPopup();" title="차량 목적지 조회 및 관리"><img src="${imgUrl}/buttonIcon_mappoint.png">&nbsp;목적지관리</a>
												<a  class="button1" href="javascript:gotoM120();" title="상세 차량 지도 보기로 이동"><img src="${imgUrl}/buttonIcon.png">&nbsp;차량관제</a>
												<a  class="button1" href="#" title="차량별 운행 일지 보기로 이동"><img src="${imgUrl}/buttonIcon_graph.png">&nbsp;운행일지</a>
											</span>
									</div>	
									<div class="scroll">
									<div class="tableTitleA">서비스 정보</div>
									<div class="map_table">
										<table class="content1" cellpadding="0" cellspacing="0" id="serviceInfo">
											<tr >
												<th class="table_title_color">서비스구분</th>
												<td id="cus_OnSubscription"></td>
											</tr>
											<tr>
												<th class="table_title_color">가입일</th>
												<td id="cus_SubscriptionDate"></td>
											</tr>
											<tr>
												<th class="table_title_color">최근수신시각</th>
												<td id="cus_DetectTime"></td>
											</tr>
											<tr>
												<th class="table_title_color">단말기번호</th>
												<td id="dev_PhoneNum"></td>
											</tr>
										</table>
									</div>
									<div class="tableTitleA">차량정보 <p> * 복수의 차량 수정 시 변경하지않는 항목은 비워두세요.</p> <a class="button1 save" id="saveCarInfo">저장</a></div>
									<div class="map_table">
										<table class="content1" cellpadding="0" cellspacing="0" id="carInfo">
											<tr >
												<th class="table_title_color">차량별칭</th>
												<td><input type="text" data-valid="128;" id="carName"></td>
											</tr>
											<tr>
												<th class="table_title_color">운전자명</th>
												<td><input type="text" data-valid="kor;num;eng;10;" id="dri_Name"></td>
											</tr>
											<tr>
												<th class="table_title_color">소속</th>
												<td>
													<select id="deptCode"
													<sec:authorize access="!hasRole('ROLE_CADMIN')">
														disabled ="true"
													</sec:authorize>
													>
													</select>
												</td>
											</tr>
											<tr>
												<th class="table_title_color">관리그룹</th>
												<td>
													<select id="carGroupCode"
													<sec:authorize access="!hasRole('ROLE_CADMIN')">
														disabled ="true"
													</sec:authorize>
													>
													</select>
													
													<sec:authorize access="hasRole('ROLE_CADMIN')">
														<a class="button1 rightPos popup_open" id="1">그룹관리...</a>	
													</sec:authorize>
												</td>
											</tr>
											<tr >
												<th class="table_title_color">운전자핸드폰</th>
												<td><input type="text" data-valid="phone;" id="dri_HandPhone"><p>*숫자로만 입력하세요.</p></td>
											</tr>
											<tr >
												<th class="table_title_color">차량종류</th>
												<td class="iconSize">
													<img class="popup_open" id="carTypeSrc" src="${imgUrl}/icon_cartype_00.png" title="클릭하여 차량 종류 선택">
													<input type="hidden" id="carType"/>
												</td>
											</tr>
											<tr >
												<th class="table_title_color">운반물내용</th>
												<td><input type="text" id="bag_BaggageName" data-valid="30;"></td>
											</tr>
											<tr >
												<th class="table_title_color">누적거리</th>
												<td><input type="text" style="width:50px;" id="baseTotalDistance" /> Km
													<p>*설정하신 누적거리를 합산하여 총 누적거리를 계산합니다.</p></td>
											</tr>
											<tr >
												<th class="table_title_color">차고지</th>
												<td><input type="text" style="width:298px;" id="garage" data-valid="50;"></td>
											</tr>
											<tr >
												<th class="table_title_color">메모</th>
												<td><textarea style="width:298px; height:44px;" id="memo" data-valid="400;"></textarea> </td>
											</tr>
											
										</table>
									</div>
									<div class="tableTitleA">차량설정 <p> * 복수의 차량 수정 시 변경하지않는 항목은 비워두세요.</p> <a class="button1 save" id="savePrivacy">저장</a></div>
									<div class="map_table">
										<table class="content1" cellpadding="0" cellspacing="0" id="privacyInfo">
											<tr >
												<th class="table_title_color">규정속도</th>
												<td><input type="text" style="width:50px;" id="regulationSpeed" data-valid="3;int;" data-max="100"> Km/h
													<p>* 규정속도 +10Km/h 초과시마다 경보이벤트를 발생시킵니다.</p>
												</td>
											</tr>
											<tr >
												<th class="table_title_color">저전압설정</th>
												<td><input type="text" style="width:50px;" id="lowVoltage" data-valid="4;long;" data-min="8" data-max="30"> V<p>(8.0 ~ 30.0 사이의 값)</p>
													<p>* 저전압시 경고이벤트를 발생시킵니다.</p>
												</td>
											</tr>
											<tr >
												<th class="table_title_color">프라이버시설정</th>
												<td>
													<div><input type="radio" name="baseprivacy" value="0" checked="checked"> 항상 위치정보를 전송함</div>
													<div>
														<input type="radio" name="baseprivacy" value="1">
														<select id="GPSAllowTimeFr" class="selectChanged">
															<option value="0">00</option>
															<option value="1">01</option>
															<option value="2">02</option>
															<option value="3">03</option>
															<option value="4">04</option>
															<option value="5">05</option>
															<option value="6">06</option>
															<option value="7">07</option>
															<option value="8">08</option>
															<option value="9">09</option>
															<option value="10">10</option>
															<option value="11">11</option>
															<option value="12">12</option>
															<option value="13">13</option>
															<option value="14">14</option>
															<option value="15">15</option>
															<option value="16">16</option>
															<option value="17">17</option>
															<option value="18">18</option>
															<option value="19">19</option>
															<option value="20">20</option>
															<option value="21">21</option>
															<option value="22">22</option>
															<option value="23">23</option>
															
															
														</select>
														시부터
														<select id="GPSAllowTimeTo" class="selectChanged">
															<option value="0">00</option>
															<option value="1">01</option>
															<option value="2">02</option>
															<option value="3">03</option>
															<option value="4">04</option>
															<option value="5">05</option>
															<option value="6">06</option>
															<option value="7">07</option>
															<option value="8">08</option>
															<option value="9">09</option>
															<option value="10">10</option>
															<option value="11">11</option>
															<option value="12">12</option>
															<option value="13">13</option>
															<option value="14">14</option>
															<option value="15">15</option>
															<option value="16">16</option>
															<option value="17">17</option>
															<option value="18">18</option>
															<option value="19">19</option>
															<option value="20">20</option>
															<option value="21">21</option>
															<option value="22">22</option>
															<option value="23">23</option>
															<option value="24">24</option>
														</select>
														시까지 위치정보 전송
													</div>
													<p>* 시간을 설정할 경우에는 설정시간 이외에는 위치정보를 파악
														할 수 없으므로 주의하여 설정하십시요. <br />
														* 법규에 의해 DTG 정보를 항상 보관해야 하는 사업자는 시간
														 설정하시면 안됩니다.
													</p>
												</td>
											</tr>
											<tr >
												<th class="table_title_color">기준온도설정</th>
												<td>
													
													<div>온도1 <input type="text" style="width:40px;" id="baeTemperature1" data-valid="5;long;" data-min="200" > ℃&nbsp;&nbsp;&nbsp;온도2 <input type="text" style="width:40px;" id="baeTemperature2" data-valid="5;long;" data-min="150;" > ℃
													</div>
													<p>* 설정하신 온도에 따라 +-1도간격으로
														경고이벤트를 발생시킵니다.
													</p>
												</td>
											</tr>
										</table>
									</div>
								</div><!--scroll end -->
							</div><!--content end -->
						</div><!--insideRightContent end -->
					
					</div><!--rightContent end -->
					
				</div><!--leftAndRight-->
	        	
        	
		</div> <!-- mainContent end -->
		</div> <!-- m300height end -->
		<div class="chart_footer">
		    <div class="footerCenter">
		       <span>Copyright ⓒ 2013 Qrotech Co.,Ltd. All rights reserved.</span>
		    </div>
	 </div>	<!-- footer end-->
	 		
	<sec:authorize access="hasRole('ROLE_CADMIN')">
<!-- 	관리자 권한이 없으면 안나옴. -->
	<div class="groupManage_popup_box popup" id="popup1">
		<div class="tableTitleA ">그룹관리<img class="popup_close" src="${imgUrl}/popup_close.png"></div>
		<div class="content">
			<div class="info"><input type="text" id="newGroupName"><a class="button2" id="btnGroupAdd">추가</a></div>
			<div class="map_table">
				<table class="content1" cellpadding="0" cellspacing="0"> 
					<tr valign="top" >
						<th class="table_title_color line" width="30px"><input type="checkbox" data-id="chk_group" data-check="parent"></th>
						<th class="table_title_color">관리그룹명</th>
					</tr>
				</table>
			</div>
			<div class="map_table_body">
				<table class="content1" cellpadding="0" cellspacing="0" id="tblMgrCarGroup">
					<tbody>
							<tr valign="top" >
								<td width="30px" class="line"><input type="checkbox" data-id="chk_group" data-check="children"></td>
								<td id="groupName">관리그룹 1</td>
								<td style="display:hidden;">
									<input type="hidden" id="carGroupCode"/>
								</td>
							</tr>
					</tbody>				
				</table>	
			</div><!-- map_table end -->
					
			<div class="Rowbtn1"><a class="button2" id="btnGroupDelete">삭제</a></div>	
		    <div class="Rowbtn2"><a class="button2 popup_close">닫기</a></div>
		</div><!-- content end-->	
	</div>	<!--groupManage_popup_box-->
	</sec:authorize>
	
	<div class="icon_popup_box popup" id="popupcarTypeSrc">
		<div class="tableTitleA ">차량종류 선택 <img class="popup_close" src="${imgUrl}/popup_close.png"></div>
		<div class="content">
			<div class="carCategories">
				<div class="category">승용차</div>
					<ul>
						<c:forEach items="${typeList }" var="type" varStatus="status">
							<c:if test="${type.carTypeCode/10>=1&&type.carTypeCode/10<2 }">
							<li onclick="chooseCarType(${type.carTypeCode})">
								<img src="${imgUrl}/icon_cartype_${type.carTypeCode }.png" title="${type.carTypeName }">
							</li>	
							</c:if>
						</c:forEach>
					</ul>
			</div><!--carCategories-->
			<div class="carCategories">
				<div class="category">버스</div>
					<ul>
						<c:forEach items="${typeList }" var="type" varStatus="status">
							<c:if test="${type.carTypeCode/10>=2&&type.carTypeCode/10<3 }">
							<li onclick="chooseCarType(${type.carTypeCode})">
								<img src="${imgUrl}/icon_cartype_${type.carTypeCode }.png" title="${type.carTypeName }">
							</li>	
							</c:if>
						</c:forEach>
					</ul>
			</div><!--carCategories-->
			<div class="carCategories">
				<div class="category">트럭</div>
					<ul>
						<c:forEach items="${typeList }" var="type" varStatus="status">
							<c:if test="${type.carTypeCode/10>=3&&type.carTypeCode/10<4 }">
							<li onclick="chooseCarType(${type.carTypeCode})">
								<img src="${imgUrl}/icon_cartype_${type.carTypeCode }.png" title="${type.carTypeName }">
							</li>	
							</c:if>
						</c:forEach>
						
					</ul>
			</div><!--carCategories-->
			<div class="carCategories">
				<div class="category">특수차</div>
					<ul>
						<c:forEach items="${typeList }" var="type" varStatus="status">
							<c:if test="${type.carTypeCode/10>=4&&type.carTypeCode/10<5 }">
							<li onclick="chooseCarType(${type.carTypeCode})">
								<img src="${imgUrl}/icon_cartype_${type.carTypeCode }.png" title="${type.carTypeName }">
							</li>	
							</c:if>
						</c:forEach>
					</ul>
			</div><!--carCategories-->
			<div class="carCategories">
				<div class="category">기타</div>
					<ul>
						<c:forEach items="${typeList }" var="type" varStatus="status">
							<c:if test="${type.carTypeCode==999 }">
							<li onclick="chooseCarType(${type.carTypeCode})">
								<img src="${imgUrl}/icon_cartype_${type.carTypeCode }.png" title="${type.carTypeName }">
							</li>	
							</c:if>
						</c:forEach>
						
					</ul>
			</div><!--carCategories-->
		</div><!--content-->
	</div><!--icon_popup_box-->

	<form id="theForm" name="theForm" action="" method="post" >
		<input type="hidden" name="carCode" id="carCode"/>
		<input type="hidden" name="addressComponent1" id="addressComponent1"/>
		<input type="hidden" name="addressComponent2" id="addressComponent2"/>
		<input type="hidden" name="deptCode" id="deptCode"/>
		<input type="hidden" name="carType" id="carType" />
		<input type="hidden" name="baggage" id="baggage"/>
		<input type="hidden" name="dev_CarDeviceCode" id="dev_CarDeviceCode"/>
		<input type="hidden" name="searchType" id="searchType"/>
		<input type="hidden" name="searchName" id="searchName" />
	</form>

  </body>
</html>
